package com.ruoyi.pingan.fymodule.thirdpa.controller;


import cn.hutool.extra.spring.SpringUtil;
import com.ruoyi.pingan.fymodule.order.model.dto.CalculateOrderDto;
import com.ruoyi.pingan.fymodule.order.model.dto.SxoSafetyShopOrderDto;
import com.ruoyi.pingan.fymodule.order.service.*;
import com.ruoyi.pingan.fymodule.order.service.impl.*;
import com.ruoyi.pingan.fymodule.thirdpa.model.dto.*;
import com.ruoyi.pingan.fymodule.thirdpa.model.vo.*;
import com.ruoyi.pingan.fymodule.thirdpa.service.PaBondService;
import com.ruoyi.pingan.fymodule.thirdpa.service.PaOrderService;
import com.ruoyi.pingan.fymodule.thirdpa.util.CommonResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



@Slf4j
@Tag(name = "平安订单分账")
@RestController
@RequestMapping("/thirdpa/order")
public class  PaOrderController extends BaseController {

    @Autowired
    private PaOrderService paOrderService;
    @Autowired
    private PaBondService paBondService;
    @Autowired
    private ISxoSafetyShopOrderService sxoSafetyShopOrderService;


    @Operation(summary = "冻结充值")
    @PostMapping(value = "/thirdFreezeRecharge")
    public CommonResult<ThirdFreezeRechargeVo> thirdFreezeRecharge(@RequestBody ThirdFreezeRechargeDto dto) {
        return CommonResult.success(paOrderService.thirdFreezeRecharge(dto));
    }

    @Operation(summary = "定时充值")
    @PostMapping(value = "/taskSafetyShopOrder")
    public CommonResult<Void> taskSafetyShopOrder(@RequestBody SxoSafetyShopOrderDto dto) {
        sxoSafetyShopOrderService.taskSafetyShopOrder(dto);
        return CommonResult.success();
    }
    @Operation(summary = "订单冻结充值计算(php->java)")
    @PostMapping(value = "/calculateOrder")
    public CommonResult<Void> calculateOrder(@RequestBody CalculateOrderDto dto) {
        sxoSafetyShopOrderService.calculateOrder(dto);
        ThirdFreezeRechargeDto rechargeDto = new ThirdFreezeRechargeDto();
        rechargeDto.setId(dto.getId());
        paOrderService.thirdFreezeRecharge(rechargeDto);
        return CommonResult.success();
    }

    @Operation(summary = "订单退款：分账撤销、补贴撤销、冻结充值撤销(php->java)")
    @PostMapping(value = "/thirdFreezeRechargeCancel")
    public CommonResult<ThirdFreezeRechargeCancelVo> thirdFreezeRechargeCancel(@RequestBody ThirdFreezeRechargeCancelDto dto) {
        return CommonResult.success(paOrderService.orderRefund(dto));
    }

    @Operation(summary = "java冻结充值撤销")
    @PostMapping(value = "/javathirdFreezeRechargeCancel")
    public CommonResult<ThirdFreezeRechargeCancelVo> javathirdFreezeRechargeCancel(@RequestBody ThirdFreezeRechargeCancelDto dto) {
        return CommonResult.success(paOrderService.thirdFreezeRechargeCancel(dto));
    }

    @Operation(summary = "补贴")
    @PostMapping(value = "/subsidyQuest")
    public CommonResult<SubsidyQuestVo> subsidyQuest(@RequestBody SubsidyQuestDto dto) {
        return CommonResult.success(paOrderService.subsidyQuest(dto));
    }

    @Operation(summary = "查询银行时间段内交易明细")
    @PostMapping(value = "/bankTransactionDetailsQuery")
    public CommonResult<BankTransactionDetailsQueryVo> bankTransactionDetailsQuery(@RequestBody BankTransactionDetailsQueryDto dto) {
        return CommonResult.success(paBondService.bankTransactionDetailsQuery(dto));
    }

    @Operation(summary = "撤销补贴")
    @PostMapping(value = "/subsidyCancel")
    public CommonResult<SubsidyQuestVo> subsidyCancel(@RequestBody SubsidyQuestDto dto) {
        return CommonResult.success(paOrderService.subsidyCancel(dto));
    }

    @Operation(summary = "分账(php->java)")
    @PostMapping(value = "/subAccountQuest")
    public CommonResult<SubAccountQuestVo> subAccountQuest(@RequestBody SubAccountQuestDto dto) {
        return CommonResult.success(paOrderService.subAccountQuest(dto));
    }

    @Operation(summary = "java->php")
    @PostMapping(value = "/orderRefundToPhp")
    public CommonResult<Void> orderRefundToPhp(@RequestBody ThirdFreezeRechargeCancelDto dto) {
        paOrderService.orderRefundToPhp(dto);
        return CommonResult.success();
    }

    @Operation(summary = "撤销分账(php->java)")
    @PostMapping(value = "/subAccountCancel")
    public CommonResult<SubAccountQuestVo> subAccountCancel(@RequestBody SubAccountQuestDto dto) {
        return CommonResult.success(paOrderService.subAccountCancel(dto));
    }

    @Operation(summary = "登记挂账(支持撤销)")
    @PostMapping(value = "/registerBillSupportWithdraw")
    public CommonResult<RegisterBillSupportWithdrawVo> registerBillSupportWithdraw(@RequestBody RegisterBillSupportWithdrawDto dto) {
        return CommonResult.success(paOrderService.registerBillSupportWithdraw(dto));
    }

    @Operation(summary = "登记挂账撤销")
    @PostMapping(value = "/revRegisterBillSupportWithdraw")
    public CommonResult<RegisterBillSupportWithdrawVo> revRegisterBillSupportWithdraw(@RequestBody RegisterBillSupportWithdrawDto dto) {
        return CommonResult.success(paOrderService.revRegisterBillSupportWithdraw(dto));
    }

    @Operation(summary = "交易终态查询")
    @PostMapping(value = "/traFinalStatusQuery")
    public CommonResult<TraFinalStatusQueryVo> traFinalStatusQuery(@RequestBody TraFinalStatusQueryDto dto) {
        return CommonResult.success(paOrderService.traFinalStatusQuery(dto));
    }


    @Operation(summary = "会员资金冻结-不验证")
    @PostMapping(value = "/membershipTrancheFreeze")
    public CommonResult<MembershipTrancheFreezeVo> membershipTrancheFreeze(@RequestBody MembershipTrancheFreezeDto dto) {
        return CommonResult.success(paBondService.membershipTrancheFreeze(dto));
    }

    @Operation(summary = "会员间交易-不验证")
    @PostMapping(value = "/memberTransaction")
    public CommonResult<MemberTransactionVo> memberTransaction(@RequestBody MemberTransactionDto dto) {
        return CommonResult.success(paBondService.memberTransaction(dto));
    }

    @Operation(summary = "申请提现或支付短信动态码")
    @PostMapping(value = "/applicationTextMsgDynamicCode")
    public CommonResult<ApplicationTextMsgDynamicCodeVo> applicationTextMsgDynamicCode(@RequestBody ApplicationTextMsgDynamicCodeDto dto) {
        return CommonResult.success(paBondService.applicationTextMsgDynamicCode(dto));
    }

    @Operation(summary = "会员提现-支持手续费")
    @PostMapping(value = "/memberWithdrawCash")
    public CommonResult<MemberWithdrawCashVo> memberWithdrawCash(@RequestBody MemberWithdrawCashDto dto) {
        return CommonResult.success(paBondService.memberWithdrawCash(dto));
    }

    @Operation(summary = "会员间交易-验证短信动态码")
    @PostMapping(value = "/memberTranVerifyTextMsgs")
    public CommonResult<MemberTranVerifyTextMsgsVo> memberTranVerifyTextMsgs(@RequestBody MemberTranVerifyTextMsgsDto dto) {
        return CommonResult.success(paBondService.memberTranVerifyTextMsgs(dto));
    }

    @Operation(summary = "查询银行提现退单信息")
    @PostMapping(value = "/bankWithdrawCashBackQuery")
    public CommonResult<BankWithdrawCashBackQueryVo> bankWithdrawCashBackQuery(@RequestBody BankWithdrawCashBackQueryDto dto) {
        return CommonResult.success(paBondService.bankWithdrawCashBackQuery(dto));
    }

    @Operation(summary = "查询会员子账号")
    @PostMapping(value = "/queryCustAcctId")
    public CommonResult<QueryCustAcctIdVo> queryCustAcctId(@RequestBody QueryCustAcctIdDto dto) {
        return CommonResult.success(paBondService.queryCustAcctId(dto));
    }

    @Operation(summary = "指定转账划款（测试专用，不能投产）")
    @PostMapping(value = "/apntTransfer")
    public CommonResult<Object> apntTransfer(@RequestBody ApntTransferDto dto) {
        return CommonResult.success(paBondService.apntTransfer(dto));
    }

    @Operation(summary = "查询资金汇总账户余额")
    @GetMapping(value = "/supAcctIdBalanceQuery")
    public CommonResult<SupAcctIdBalanceQueryVo> supAcctIdBalanceQuery() {
        return CommonResult.success(paBondService.supAcctIdBalanceQuery());
    }

    @Operation(summary = "会员间交易退款-不验证")
    @PostMapping(value = "/memberTransactionRefund")
    public CommonResult<MemberTransactionRefundVo> memberTransactionRefund(@RequestBody MemberTransactionRefundDto dto) {
        return CommonResult.success(paBondService.memberTransactionRefund(dto));
    }

    @Operation(summary = "查询对账文件信息")
    @PostMapping(value = "/reconciliationDocumentQuery")
    public CommonResult<ReconciliationDocumentQueryVo> reconciliationDocumentQuery(@RequestBody ReconciliationDocumentQueryDto dto) {
        return CommonResult.success(paBondService.reconciliationDocumentQuery(dto));
    }


    @Operation(summary = "查询银行时间段内清分提现明细")
    @PostMapping(value = "/bankWithdrawCashDetailsQuery")
    public CommonResult<BankWithdrawCashDetailsQueryVo> bankWithdrawCashDetailsQuery(@RequestBody BankWithdrawCashDetailsQueryDto dto) {
        return CommonResult.success(paBondService.bankWithdrawCashDetailsQuery(dto));
    }

    @Operation(summary = "查询明细单验证码")
    @PostMapping(value = "/detailVerifiedCodeQuery")
    public CommonResult<DetailVerifiedCodeQueryVo> detailVerifiedCodeQuery(@RequestBody DetailVerifiedCodeQueryDto dto) {
        return CommonResult.success(paBondService.detailVerifiedCodeQuery(dto));
    }

    @Operation(summary = "查询银行在途清算结果")
    @PostMapping(value = "/bankClearQuery")
    public CommonResult<BankClearQueryVo> bankClearQuery(@RequestBody BankClearQueryDto dto) {
        return CommonResult.success(paBondService.bankClearQuery(dto));
    }

    @Operation(summary = "查询银行单笔交易状态")
    @PostMapping(value = "/singleTransactionStatusQuery")
    public CommonResult<SingleTransactionStatusQueryVo> singleTransactionStatusQuery(@RequestBody SingleTransactionStatusQueryDto dto) {
        return CommonResult.success(paBondService.singleTransactionStatusQuery(dto));
    }

    @Operation(summary = "查询银行费用扣收结果")
    @PostMapping(value = "/bankCostDsDealResultQuery")
    public CommonResult<BankCostDsDealResultQueryVo> bankCostDsDealResultQuery(@RequestBody BankCostDsDealResultQueryDto dto) {
        return CommonResult.success(paBondService.bankCostDsDealResultQuery(dto));
    }

    @Operation(summary = "查询普通转账充值明细")
    @PostMapping(value = "/commonTransferRechargeQuery")
    public CommonResult<CommonTransferRechargeQueryVo> commonTransferRechargeQuery(@RequestBody CommonTransferRechargeQueryDto dto) {
        return CommonResult.success(paBondService.commonTransferRechargeQuery(dto));
    }

    @Operation(summary = "查询会员子账号余额")
    @GetMapping(value = "/queryCustAcctIdBalance")
    public CommonResult<QueryCustAcctIdBalanceVo> queryCustAcctIdBalance(String subAcctNo) {
        return CommonResult.success(paBondService.queryCustAcctIdBalance(subAcctNo));
    }

    @Operation(summary = "查询充值明细-见证收单")
    @PostMapping(value = "/chargeDetailQuery")
    public CommonResult<ChargeDetailQueryVo> chargeDetailQuery(@RequestBody ChargeDetailQueryDto dto) {
        return CommonResult.success(paBondService.chargeDetailQuery(dto));
    }

    @Operation(summary = "调账-见证收单")
    @PostMapping(value = "/accountRegulation")
    public CommonResult<AccountRegulationVo> accountRegulation(@RequestBody AccountRegulationDto dto) {
        return CommonResult.success(paBondService.accountRegulation(dto));
    }

    @Operation(summary = "平台补账-见证收单")
    @PostMapping(value = "/platformAccountSupply")
    public CommonResult<PlatformAccountSupplyVo> platformAccountSupply(@RequestBody PlatformAccountSupplyDto dto) {
        return CommonResult.success(paBondService.platformAccountSupply(dto));
    }

    @Operation(summary = "查询子帐号历史余额及待转可提现状态信息")
    @PostMapping(value = "/custAcctIdHistoryBalanceQuery")
    public CommonResult<CustAcctIdHistoryBalanceQueryVo> custAcctIdHistoryBalanceQuery(@RequestBody CustAcctIdHistoryBalanceQueryDto dto) {
        return CommonResult.success(paBondService.custAcctIdHistoryBalanceQuery(dto));
    }
    @Operation(summary = "冻结充值查询6273_6267")
    @GetMapping(value = "/execute6273_6267")
    public CommonResult<Void> execute6273_6267() {
        ISxoSafetyOrderService sxoSafetyOrderService = SpringUtil.getBean(SxoSafetyOrderServiceImpl.class);
        sxoSafetyOrderService.execute6273_6267();
        return CommonResult.success();
    }

    /*@Operation(summary = "查询273_6269")
    @GetMapping(value = "/execute6273_6269")
    public CommonResult<Void> execute6273_6269() {
        ISxoSafetyOrderSubsidyService sxoSafetyOrderService = SpringUtil.getBean(SxoSafetyOrderSubsidyServiceImpl.class);
        sxoSafetyOrderService.execute6273_6269();
        return CommonResult.success();
    }
*/
    @Operation(summary = "分账查询6273_6271")
    @GetMapping(value = "/execute6273_6271")
    public CommonResult<Void> execute6273_6271() {
        ISxoSafetySepAccService sxoSafetyOrderService = SpringUtil.getBean(SxoSafetySepAccServiceImpl.class);
        sxoSafetyOrderService.execute6273_6271();
        return CommonResult.success();
    }

    @Operation(summary = "分账撤销查询6273_6272")
    @GetMapping(value = "/execute6273_6272")
    public CommonResult<Void> execute6273_6272() {
        ISxoSafetySepAccRevokeService sxoSafetyOrderService = SpringUtil.getBean(SxoSafetySepAccRevokeServiceImpl.class);
        sxoSafetyOrderService.execute6273_6272();
        return CommonResult.success();
    }

    @Operation(summary = "冻结充值撤退查询6273_6268")
    @GetMapping(value = "/execute6273_6268")
    public CommonResult<Void> execute6273_6268() {
        ISxoSafetyOrderRevokeService sxoSafetyOrderService = SpringUtil.getBean(SxoSafetyOrderRevokeServiceImpl.class);
        sxoSafetyOrderService.execute6273_6268();
        return CommonResult.success();
    }

    @Operation(summary = "商家提现")
    @GetMapping(value = "/executeSettlement")
    public CommonResult<Void> executeSettlement(SettlementDto dto) {
        ISxoSafetySepAccService sxoSafetyOrderService = SpringUtil.getBean(SxoSafetySepAccServiceImpl.class);
        sxoSafetyOrderService.executeSettlement(dto);
        return CommonResult.success();
    }




}
